<template>
  <div>
    <el-button type="primary" style="float:right;" @click="dialogVisible = true">修改</el-button>

      <el-dialog
          title="提示"
          :visible.sync="dialogVisible"
          width="30%"
          :before-close="handleClose">
      <span>
          <el-form>
            <el-form-item>
                <el-input v-show="false" v-model="user.uid"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input show-password v-model="user.password"></el-input>
            </el-form-item>

          </el-form>
        </span>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="up">确 定</el-button>
  </span>

      </el-dialog>


    <div class="block">
        <el-avatar shape="square" :size="100" >
        <img :src="'data:image/*;base64,'+user.photo" ></el-avatar>
      </div>

    <el-descriptions title="账号信息" direction="vertical" :column="4" border>
      <el-descriptions-item label="用户编号">{{user.uid}}</el-descriptions-item>
      <el-descriptions-item label="用户类型" :span="3">{{user.usertype.typename}}</el-descriptions-item>
      <el-descriptions-item label="用户姓名">{{ user.username }}</el-descriptions-item>
    </el-descriptions>
  </div>
</template>
<script>

import axios from "axios";
import user from "@/components/guanli/view/User.vue";

export default {
  name: "My",
  data(){
    return{
      user:[],
      dialogVisible:false,
      uid:''
    }
  },
  methods:{
    up(){
      axios.post("/user/uppass",this.user).then(resp=>{
        if(resp.data.flag){
          this.$message.success("修改密码成功")
          this.findAll();
          this.dialogVisible=false
        }
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
    },
    findAll(){
      this.uid=JSON.parse(window.sessionStorage.getItem("user")).uid;

      axios.get("user/userid/",{params:{uid:this.uid}}).then(resp =>{
        if(resp) {
          this.user= resp.data.data;
          console.log(resp.data.data)
        }
      })
    }
  },
  created() {
    this.findAll();
  }
}
</script>

<style scoped>

</style>